#import "Core.h"

@implementation PurposeData

@synthesize purpose = _purpose;
@synthesize date = _date;

- (id)initWithPurpose:(NSString*)purpose date:(NSDate*)date
{
	if( (self = [super init]) != nil )
	{
		self.purpose = purpose;
		self.date = date;
	}
	
	return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
	if( (self = [super init]) != nil )
	{
		self.purpose = (NSString*)[aDecoder decodeObjectForKey:@"purpose"];
		self.date = (NSDate*)[aDecoder decodeObjectForKey:@"date"];
	}
	return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
	[aCoder encodeObject:self.purpose forKey:@"purpose"];
	[aCoder encodeObject:self.date forKey:@"date"];
}

@end

@implementation PurposeDataList 

- (id)init 
{
	if( (self = [super init]) != nil )
	{
		_purposeList = [[NSMutableArray alloc] init];
	}
	
	return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
	if( (self = [super init]) != nil )
	{
		_purposeList = [(NSMutableArray*)[aDecoder decodeObjectForKey:@"purposeList"] retain];
	}
	return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
	[aCoder encodeObject:_purposeList forKey:@"purposeList"];
}

- (NSInteger)getNumberOfData
{
	return [_purposeList count];
}

- (void)addPurpose:(NSString*)purpose
{
	[_purposeList addObject:[[PurposeData alloc] initWithPurpose:purpose date:[NSDate date]]];
}

- (void)addPurposeData:(PurposeData *)purposeData
{
	[_purposeList addObject:purposeData];
}

- (PurposeData*)getPurposeWithIndex:(NSInteger)index
{
	return [_purposeList objectAtIndex:index];
}

- (void)deletePurposeAtIndex:(NSInteger)index
{
	[_purposeList removeObjectAtIndex:index];
}

@end
